<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 */
namespace Admin\Controller;

use Common\Api\GameApi;
use Common\Api\GamePrizegethisApi;
// use Admin\Model\GameModel;
use Admin\Controller\AdminController;

class GamePrizegethisController extends AdminController{
    // protected  $model;
    // protected  $url;

    protected function _initialize() {
        parent::_initialize();
        // $this->model = D('Game');
        // $this->url = U('Admin/Game/index', array());
    }

    /**
     * show game list
     * @return [tpl]
     */
    public function index($gid,$p=1){
        $game = $this->getGameById($gid);
        $this->assignTitle($game['name'].' - 中奖记录');
        $this->assign('game',$game);
        $r = apiCall(GamePrizegethisApi::FINDS,array($gid,$p));
        if($r['status'])
        {
            $this->assign('list',$r['info']['list']);
            $this->assign('show',$r['info']['show']);

        }else $this->error('查询失败');
        $this->display(); // 输出模板
    }

    protected function getGameById($gid){
        $r = apiCall(GameApi::FIND,array(array('id'=>$gid)));
        if(!$r || !$r['status']) $this->error('GameApi:find:error');
        // if(!$r['info']) $this->error('错误抽奖');
        return $r['info'];
    }
}

